\(\int \tan (c+d x) (a+i a \tan (c+d x)) (A+B \tan (c+d x)) \, dx\) [2]

   Optimal result
   Rubi [A] (verified)
   Mathematica [A] (verified)
   Maple [A] (verified)
   Fricas [A] (verification not implemented)
   Sympy [A] (verification not implemented)
   Maxima [A] (verification not implemented)
   Giac [B] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 30, antiderivative size = 69 \[ \int \tan (c+d x) (a+i a \tan (c+d x)) (A+B \tan (c+d x)) \, dx=-a (i A+B) x-\frac {a (A-i B) \log (\cos (c+d x))}{d}+\frac {a (i A+B) \tan (c+d x)}{d}+\frac {i a B \tan ^2(c+d x)}{2 d} \]

[Out]

-a*(I*A+B)*x-a*(A-I*B)*ln(cos(d*x+c))/d+a*(I*A+B)*tan(d*x+c)/d+1/2*I*a*B*tan(d*x+c)^2/d

Rubi [A] (verified)

Time = 0.07 (sec) , antiderivative size = 69, normalized size of antiderivative = 1.00, number of steps used = 3, number of rules used = 3, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.100, Rules used = {3673, 3606, 3556} \[ \int \tan (c+d x) (a+i a \tan (c+d x)) (A+B \tan (c+d x)) \, dx=\frac {a (B+i A) \tan (c+d x)}{d}-\frac {a (A-i B) \log (\cos (c+d x))}{d}-a x (B+i A)+\frac {i a B \tan ^2(c+d x)}{2 d} \]

[In]

Int[Tan[c + d*x]*(a + I*a*Tan[c + d*x])*(A + B*Tan[c + d*x]),x]

[Out]

-(a*(I*A + B)*x) - (a*(A - I*B)*Log[Cos[c + d*x]])/d + (a*(I*A + B)*Tan[c + d*x])/d + ((I/2)*a*B*Tan[c + d*x]^
2)/d

Rule 3556

Int[tan[(c_.) + (d_.)*(x_)], x_Symbol] :> Simp[-Log[RemoveContent[Cos[c + d*x], x]]/d, x] /; FreeQ[{c, d}, x]

Rule 3606

Int[((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)])*((c_.) + (d_.)*tan[(e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[(a*c - b
*d)*x, x] + (Dist[b*c + a*d, Int[Tan[e + f*x], x], x] + Simp[b*d*(Tan[e + f*x]/f), x]) /; FreeQ[{a, b, c, d, e
, f}, x] && NeQ[b*c - a*d, 0] && NeQ[b*c + a*d, 0]

Rule 3673

Int[((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_.)*((A_.) + (B_.)*tan[(e_.) + (f_.)*(x_)])*((c_.) + (d_.)*tan[(
e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[B*d*((a + b*Tan[e + f*x])^(m + 1)/(b*f*(m + 1))), x] + Int[(a + b*Tan[e
 + f*x])^m*Simp[A*c - B*d + (B*c + A*d)*Tan[e + f*x], x], x] /; FreeQ[{a, b, c, d, e, f, A, B, m}, x] && NeQ[b
*c - a*d, 0] &&  !LeQ[m, -1]

Rubi steps \begin{align*} \text {integral}& = \frac {i a B \tan ^2(c+d x)}{2 d}+\int \tan (c+d x) (a (A-i B)+a (i A+B) \tan (c+d x)) \, dx \\ & = -a (i A+B) x+\frac {a (i A+B) \tan (c+d x)}{d}+\frac {i a B \tan ^2(c+d x)}{2 d}+(a (A-i B)) \int \tan (c+d x) \, dx \\ & = -a (i A+B) x-\frac {a (A-i B) \log (\cos (c+d x))}{d}+\frac {a (i A+B) \tan (c+d x)}{d}+\frac {i a B \tan ^2(c+d x)}{2 d} \\ \end{align*}

Mathematica [A] (verified)

Time = 0.33 (sec) , antiderivative size = 70, normalized size of antiderivative = 1.01 \[ \int \tan (c+d x) (a+i a \tan (c+d x)) (A+B \tan (c+d x)) \, dx=\frac {a \left ((-2 i A-2 B) \arctan (\tan (c+d x))-2 (A-i B) \log (\cos (c+d x))+2 (i A+B) \tan (c+d x)+i B \tan ^2(c+d x)\right )}{2 d} \]

[In]

Integrate[Tan[c + d*x]*(a + I*a*Tan[c + d*x])*(A + B*Tan[c + d*x]),x]

[Out]

(a*(((-2*I)*A - 2*B)*ArcTan[Tan[c + d*x]] - 2*(A - I*B)*Log[Cos[c + d*x]] + 2*(I*A + B)*Tan[c + d*x] + I*B*Tan
[c + d*x]^2))/(2*d)

Maple [A] (verified)

Time = 0.05 (sec) , antiderivative size = 72, normalized size of antiderivative = 1.04

method result size
derivativedivides \(\frac {a \left (\frac {i B \left (\tan ^{2}\left (d x +c \right )\right )}{2}+i A \tan \left (d x +c \right )+B \tan \left (d x +c \right )+\frac {\left (-i B +A \right ) \ln \left (1+\tan ^{2}\left (d x +c \right )\right )}{2}+\left (-i A -B \right ) \arctan \left (\tan \left (d x +c \right )\right )\right )}{d}\) \(72\)
default \(\frac {a \left (\frac {i B \left (\tan ^{2}\left (d x +c \right )\right )}{2}+i A \tan \left (d x +c \right )+B \tan \left (d x +c \right )+\frac {\left (-i B +A \right ) \ln \left (1+\tan ^{2}\left (d x +c \right )\right )}{2}+\left (-i A -B \right ) \arctan \left (\tan \left (d x +c \right )\right )\right )}{d}\) \(72\)
norman \(\left (-i a A -B a \right ) x +\frac {\left (i a A +B a \right ) \tan \left (d x +c \right )}{d}+\frac {i a B \left (\tan ^{2}\left (d x +c \right )\right )}{2 d}+\frac {\left (-i a B +a A \right ) \ln \left (1+\tan ^{2}\left (d x +c \right )\right )}{2 d}\) \(74\)
parts \(\frac {\left (i a A +B a \right ) \left (\tan \left (d x +c \right )-\arctan \left (\tan \left (d x +c \right )\right )\right )}{d}+\frac {a A \ln \left (1+\tan ^{2}\left (d x +c \right )\right )}{2 d}+\frac {i a B \left (\frac {\left (\tan ^{2}\left (d x +c \right )\right )}{2}-\frac {\ln \left (1+\tan ^{2}\left (d x +c \right )\right )}{2}\right )}{d}\) \(81\)
parallelrisch \(-\frac {2 i A x a d -i a B \left (\tan ^{2}\left (d x +c \right )\right )-2 i A \tan \left (d x +c \right ) a +i B \ln \left (1+\tan ^{2}\left (d x +c \right )\right ) a +2 B x a d -a A \ln \left (1+\tan ^{2}\left (d x +c \right )\right )-2 B \tan \left (d x +c \right ) a}{2 d}\) \(85\)
risch \(\frac {2 a B c}{d}+\frac {2 i a A c}{d}+\frac {2 i a \left (i A \,{\mathrm e}^{2 i \left (d x +c \right )}+2 B \,{\mathrm e}^{2 i \left (d x +c \right )}+i A +B \right )}{d \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right )^{2}}+\frac {i a \ln \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right ) B}{d}-\frac {a \ln \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right ) A}{d}\) \(109\)

[In]

int(tan(d*x+c)*(a+I*a*tan(d*x+c))*(A+B*tan(d*x+c)),x,method=_RETURNVERBOSE)

[Out]

1/d*a*(1/2*I*B*tan(d*x+c)^2+I*A*tan(d*x+c)+B*tan(d*x+c)+1/2*(A-I*B)*ln(1+tan(d*x+c)^2)+(-I*A-B)*arctan(tan(d*x
+c)))

Fricas [A] (verification not implemented)

none

Time = 0.24 (sec) , antiderivative size = 109, normalized size of antiderivative = 1.58 \[ \int \tan (c+d x) (a+i a \tan (c+d x)) (A+B \tan (c+d x)) \, dx=-\frac {2 \, {\left (A - 2 i \, B\right )} a e^{\left (2 i \, d x + 2 i \, c\right )} + 2 \, {\left (A - i \, B\right )} a + {\left ({\left (A - i \, B\right )} a e^{\left (4 i \, d x + 4 i \, c\right )} + 2 \, {\left (A - i \, B\right )} a e^{\left (2 i \, d x + 2 i \, c\right )} + {\left (A - i \, B\right )} a\right )} \log \left (e^{\left (2 i \, d x + 2 i \, c\right )} + 1\right )}{d e^{\left (4 i \, d x + 4 i \, c\right )} + 2 \, d e^{\left (2 i \, d x + 2 i \, c\right )} + d} \]

[In]

integrate(tan(d*x+c)*(a+I*a*tan(d*x+c))*(A+B*tan(d*x+c)),x, algorithm="fricas")

[Out]

-(2*(A - 2*I*B)*a*e^(2*I*d*x + 2*I*c) + 2*(A - I*B)*a + ((A - I*B)*a*e^(4*I*d*x + 4*I*c) + 2*(A - I*B)*a*e^(2*
I*d*x + 2*I*c) + (A - I*B)*a)*log(e^(2*I*d*x + 2*I*c) + 1))/(d*e^(4*I*d*x + 4*I*c) + 2*d*e^(2*I*d*x + 2*I*c) +
 d)

Sympy [A] (verification not implemented)

Time = 0.28 (sec) , antiderivative size = 109, normalized size of antiderivative = 1.58 \[ \int \tan (c+d x) (a+i a \tan (c+d x)) (A+B \tan (c+d x)) \, dx=- \frac {a \left (A - i B\right ) \log {\left (e^{2 i d x} + e^{- 2 i c} \right )}}{d} + \frac {- 2 A a + 2 i B a + \left (- 2 A a e^{2 i c} + 4 i B a e^{2 i c}\right ) e^{2 i d x}}{d e^{4 i c} e^{4 i d x} + 2 d e^{2 i c} e^{2 i d x} + d} \]

[In]

integrate(tan(d*x+c)*(a+I*a*tan(d*x+c))*(A+B*tan(d*x+c)),x)

[Out]

-a*(A - I*B)*log(exp(2*I*d*x) + exp(-2*I*c))/d + (-2*A*a + 2*I*B*a + (-2*A*a*exp(2*I*c) + 4*I*B*a*exp(2*I*c))*
exp(2*I*d*x))/(d*exp(4*I*c)*exp(4*I*d*x) + 2*d*exp(2*I*c)*exp(2*I*d*x) + d)

Maxima [A] (verification not implemented)

none

Time = 0.34 (sec) , antiderivative size = 68, normalized size of antiderivative = 0.99 \[ \int \tan (c+d x) (a+i a \tan (c+d x)) (A+B \tan (c+d x)) \, dx=-\frac {-i \, B a \tan \left (d x + c\right )^{2} - 2 \, {\left (d x + c\right )} {\left (-i \, A - B\right )} a - {\left (A - i \, B\right )} a \log \left (\tan \left (d x + c\right )^{2} + 1\right ) + 2 \, {\left (-i \, A - B\right )} a \tan \left (d x + c\right )}{2 \, d} \]

[In]

integrate(tan(d*x+c)*(a+I*a*tan(d*x+c))*(A+B*tan(d*x+c)),x, algorithm="maxima")

[Out]

-1/2*(-I*B*a*tan(d*x + c)^2 - 2*(d*x + c)*(-I*A - B)*a - (A - I*B)*a*log(tan(d*x + c)^2 + 1) + 2*(-I*A - B)*a*
tan(d*x + c))/d

Giac [B] (verification not implemented)

Both result and optimal contain complex but leaf count of result is larger than twice the leaf count of optimal. 194 vs. \(2 (59) = 118\).

Time = 0.34 (sec) , antiderivative size = 194, normalized size of antiderivative = 2.81 \[ \int \tan (c+d x) (a+i a \tan (c+d x)) (A+B \tan (c+d x)) \, dx=-\frac {A a e^{\left (4 i \, d x + 4 i \, c\right )} \log \left (e^{\left (2 i \, d x + 2 i \, c\right )} + 1\right ) - i \, B a e^{\left (4 i \, d x + 4 i \, c\right )} \log \left (e^{\left (2 i \, d x + 2 i \, c\right )} + 1\right ) + 2 \, A a e^{\left (2 i \, d x + 2 i \, c\right )} \log \left (e^{\left (2 i \, d x + 2 i \, c\right )} + 1\right ) - 2 i \, B a e^{\left (2 i \, d x + 2 i \, c\right )} \log \left (e^{\left (2 i \, d x + 2 i \, c\right )} + 1\right ) + 2 \, A a e^{\left (2 i \, d x + 2 i \, c\right )} - 4 i \, B a e^{\left (2 i \, d x + 2 i \, c\right )} + A a \log \left (e^{\left (2 i \, d x + 2 i \, c\right )} + 1\right ) - i \, B a \log \left (e^{\left (2 i \, d x + 2 i \, c\right )} + 1\right ) + 2 \, A a - 2 i \, B a}{d e^{\left (4 i \, d x + 4 i \, c\right )} + 2 \, d e^{\left (2 i \, d x + 2 i \, c\right )} + d} \]

[In]

integrate(tan(d*x+c)*(a+I*a*tan(d*x+c))*(A+B*tan(d*x+c)),x, algorithm="giac")

[Out]

-(A*a*e^(4*I*d*x + 4*I*c)*log(e^(2*I*d*x + 2*I*c) + 1) - I*B*a*e^(4*I*d*x + 4*I*c)*log(e^(2*I*d*x + 2*I*c) + 1
) + 2*A*a*e^(2*I*d*x + 2*I*c)*log(e^(2*I*d*x + 2*I*c) + 1) - 2*I*B*a*e^(2*I*d*x + 2*I*c)*log(e^(2*I*d*x + 2*I*
c) + 1) + 2*A*a*e^(2*I*d*x + 2*I*c) - 4*I*B*a*e^(2*I*d*x + 2*I*c) + A*a*log(e^(2*I*d*x + 2*I*c) + 1) - I*B*a*l
og(e^(2*I*d*x + 2*I*c) + 1) + 2*A*a - 2*I*B*a)/(d*e^(4*I*d*x + 4*I*c) + 2*d*e^(2*I*d*x + 2*I*c) + d)

Mupad [B] (verification not implemented)

Time = 7.89 (sec) , antiderivative size = 59, normalized size of antiderivative = 0.86 \[ \int \tan (c+d x) (a+i a \tan (c+d x)) (A+B \tan (c+d x)) \, dx=\frac {\ln \left (\mathrm {tan}\left (c+d\,x\right )+1{}\mathrm {i}\right )\,\left (A\,a-B\,a\,1{}\mathrm {i}\right )}{d}+\frac {\mathrm {tan}\left (c+d\,x\right )\,\left (B\,a+A\,a\,1{}\mathrm {i}\right )}{d}+\frac {B\,a\,{\mathrm {tan}\left (c+d\,x\right )}^2\,1{}\mathrm {i}}{2\,d} \]

[In]

int(tan(c + d*x)*(A + B*tan(c + d*x))*(a + a*tan(c + d*x)*1i),x)

[Out]

(log(tan(c + d*x) + 1i)*(A*a - B*a*1i))/d + (tan(c + d*x)*(A*a*1i + B*a))/d + (B*a*tan(c + d*x)^2*1i)/(2*d)